
'''
跨品台版本的多进程模块, 提供一个Process类来代表一个进程对象
'''

from multiprocessing import Process
from time import sleep
import os


def run(good, ok):
    while True:
        print("子进程在干活: " + good + ok + "当前进程ID: " + str(os.getpid()) + "当前进程的父进程ID: " + str(os.getppid()) )
        sleep(1)


if __name__ == "__main__":
    print("父进程启动:")

    # 创建子进程, target表示子进程执行的任务方法
    p = Process(target=run, args=("good-", "ok"))

    p.start()

    while True:
        print("父进程在干活"+ "当前进程ID: " + str(os.getpid()))
        sleep(2)
